package java;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class java{
	public static void main(String[] args){
		BufferedReader br = null;
		try{
			File file = new File("E:\\java.txt")；
			if(!file.exists()){
				file.createNewFile();
			}
			ProcessBuilder pb = new ProcessBuilder().command("cmd.exe","/c","java -version").inheritIO();
			pb.redirectErrorStream(true);
			pd.redirectOutput(file);
			pb.start().waitFor();
			InputStream in= new FileInputStream(file);
			br = new BufferedReader(new InputStreamReader(in));
			String line = null;
			while((line = br.readLine()) != null){
				System.out.println(line);
			}
			br.close();
			br = null;
			file.delete();
		} catch(Exception e){
			e.printStackTrace();
		} finally{
			if(br != null){
				try{
					br.close();
				} catch(IOException e){
					e.printStackTrace();
				}
			}
		}
	}
}